package com.platform.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.platform.entity.Product;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ProductMapper extends BaseMapper<Product> {

    IPage<Product> findPage(Page<Product> page, @Param("name") String name);

    @Select("select * from product where category_id = #{id}")
    IPage<Product> pageByCategory(Page<Product> page, @Param("id") Long id);

    List<Product> getRecommend();

    @Select("select * from product order by sales desc limit 0,3")
    List<Product> sales();
//    @Select("select * from classify")
    List<Product> findAll();

}
